package com.boot.unity.api.modules.train.service.impl;

import com.boot.unity.api.modules.train.dao.AchievementDao;
import com.boot.unity.api.modules.train.dto.AchievementDTO;
import com.boot.unity.api.modules.train.entity.Achievement;
import com.boot.unity.api.modules.train.result.Result;
import com.boot.unity.api.modules.train.service.AchievementService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
/**
 * @author anonymous
 *
 * @create 2020-09-08 16:31:58
 */
@Slf4j
@Service
@AllArgsConstructor
public class AchievementServiceImpl implements AchievementService {

    private final AchievementDao achievementDao;

    @Override
    public Result save(AchievementDTO achievementDTO) {
        try {
            Achievement achievement = new Achievement();
            BeanUtils.copyProperties(achievementDTO,achievement);
            achievementDao.save(achievement);
            return Result.success("保存考试成绩成功!");
        }catch (Exception e){
            e.printStackTrace();
            log.error("保存考试成绩失败[{}]",e.getMessage());
        }
        return Result.fail("保存考试成绩失败!");
    }
}
